﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Hotnet.Entity.SourceFrom>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	来源网站管理 - Hotent后台管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>
		来源网站管理</h2>
	<table width="100%" class="ma list">
		<tr>
			<th width="50px;">
				网站ID
			</th>
			<th>
				网站名称
			</th>
			<th>
				网站URL
			</th>
			<th>
				网站类型
			</th>
			<th>
				LogoURL
			</th>
			<th>
				操作
			</th>
		</tr>
		<% foreach (var item in Model) { %>
		<tr>
			<td style=" text-align:center">
				<%= Html.Encode(item.SourceFromID) %>
			</td>
			<td>
				<%= Html.Encode(item.Name) %>
			</td>
			<td>
				<%= Html.Encode(item.Url) %>
			</td>
			<td>
				<%= Html.Encode(item.NetType==null?"":Convert.ToString((EnumSystemCategory)item.NetType)) %>
			</td>
			<td>
				<%if(string.IsNullOrEmpty(item.LogoUrl)){ %>
				无LOGO
				<%}else{ %>
				<img alt="<%= Html.Encode(item.Name) %>" src="<%= Html.Encode(item.LogoUrl) %>" />
				<%} %>
			</td>
			<td style=" text-align:center">
				<a href="javascript:editSourceFrom(<%=item.SourceFromID %>, '<%=item.Name%>','<%=item.Url %>','<%=item.LogoUrl %>','<%=item.NetType %>')">编辑</a> |
				<a href="javascript:confirmDelete('确定删除此来源网站?', '/AdminSourceFrom/Delete/', <%=item.SourceFromID %>);">删除</a> 
			</td>
		</tr>
		<% } %>
	</table>

	<p>
		<a href="javascript:newSourceFrom();" class="b1 p5 dbk blik fl">新增来源网站</a>
	</p>
	<div id="createWindow" style="display:none;">
		<%using (Html.BeginForm("Create", "AdminSourceFrom", FormMethod.Post, new { id="formMutiple"})) {%>
		<input type="hidden" name="SourceFromID" id="SourceFromID" />
		<div class="tac ma">
			<span class="mr3" style=" margin-right:10px;">网站名称:</span>
			<input type="text" name="Name" id="Name" />
		</div>
		<div class="tac ma">
			<span class="mr3" style=" margin-right:10px;">网站URL:</span>
			<input type="text" name="Url" id="Url" />
		</div>
		
		<div>
			<span class="mr3" style=" margin-right:10px; margin-left:20px;">网站类型:</span>
			<%=Html.DropDownList("NetType", ConvertEnumToSelectList.ComposeSelectListFromEnum<EnumSystemCategory>())%>
		</div>
		
		<div class="tac ma">
			<span class="mr3">LogoURL:</span>
			<input type="text" name="LogoUrl" id="LogoUrl" />
		</div>
		
		<div style="text-align:center; margin-top:5px;">
			<input type="submit" value="确定" class="ml3 boxy-button"/>
			<input type="button" value="关闭" class="ml3 boxy-button" onclick="closeWindow();" />
		</div>
		<% } %>
	</div>
	
	<script type="text/javascript">
		var boxy;
		function showWindow() {
			if (boxy == null)
				boxy = new Boxy($('#createWindow'), { modal: false, title: '新增来源网站', closeText: '[×]', draggable: true }).resize(310, 100);
			else
				boxy.show();
		}
		function closeWindow() {
			boxy.hide();
		}

		function newSourceFrom() {
			$("#formMutiple").attr("action", "/AdminSourceFrom/Create");
			$("#Name").val("");
			$("#Url").val("");
			$("#LogoUrl").val("");
			$("#SourceFromID").val("");

			showWindow();
			boxy.setTitle("新增来源网站");
		}

		function editSourceFrom(sourceFromId, name, url, logoUrl,netType) {
			$("#formMutiple").attr("action", "/AdminSourceFrom/Edit");
			$("#SourceFromID").val(sourceFromId);
			$("#Name").val(name);
			$("#Url").val(url);
			$("#LogoUrl").val(logoUrl);
			$("#NetType").val(netType);
			showWindow();
			boxy.setTitle("编辑来源网站");
		}
	</script>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="StyleContent" runat="server">
</asp:Content>

